Field of the Invention
The invention is directed to a method and an apparatus for image processing and more particularly, to a method and an electronic apparatus for image background learning.
Description of Related Art
In a background learning technique, a plurality of images obtained by capturing the same scene is analyzed and thereby, a background model of the scene is obtained. The background model may be used to distinguish a foreground and a background of subsequently captured images, so that the processed images may be used in various applications, such as movement detection, pedestrian detection and so on.
FIG. 1 and FIG. 2 are schematic diagrams illustrating conventional background learning techniques. Referring to FIG. 1, in an algorithm of the conventional background learning technique, a stable background model 10 is obtained through learning a plurality of images, and the background model 10 includes an object 102. Assuming an input image 12 includes a new object 104, the input image 12 is compared with the background model 10 by the algorithm, so as to output a foreground mask image 14. The foreground mask image 14 includes an object 106 which is labeled as a foreground and represents a moving foreground.
Then, referring to FIG. 2, when performing the background learning, the algorithm may dispose a memory space capable of storing historic values for each pixel in the input image. For example, a memory space 22 capable of recording 10 historic values is disposed for an ith pixel 202 in a tth image 20 illustrated in FIG. 2. Then, the algorithm compares the pixel value of the pixel 202 with each historical values in the memory space, so as to determine whether they match each other. If they match each other, the algorithm marks the pixel 202 as a background pixel, and updates one of the historic values in the memory space 22 by using the pixel value of the pixel 202. When performing the updating operation, the algorithm, for example, adopts a sequential updating method to sequentially update the historic values in the memory space 22 by using the pixel value of the pixel that is newly determined as the background pixel, or adopts a random updating method to randomly update any one of the historic values in the memory space 22 by using the pixel value of the pixel that is newly determined as the background pixel.
However, the background in an actual scene is not imaginarily stable, which may be influenced by image coding errors, and even some minor changes (e.g., a slightly shaking leaf, signboard and so on) in the scene may cause foreground noise. Thus, the background memory has to be sufficient for the conventional background learning technique to identify such interference. However, if the background memory is not adaptively adjusted (e.g. a length of the memory is too long), an object of interest may be mistakenly considered as the background and then ignored.